package com.example.androidnote.api;

import com.common.common.RxSchedulers;
import com.example.androidnote.MyApplication;
import com.example.androidnote.api.remote.IApiService;
import com.example.androidnote.domain.MainDomain;

import io.reactivex.Observable;

public class IApiDataSourceImpl implements IApiDataSource {

    public static IApiDataSourceImpl getInstance() {
        return IApiDataSourceImpl.SingletonHolder.instance;
    }

    private static class SingletonHolder {
        static IApiDataSourceImpl instance = new IApiDataSourceImpl();
    }

    private static IApiService sIApiService;
    static {
        sIApiService = MyApplication.getNetUtil().getApiService();
    }
    public static IApiService getIApiService(){
        return sIApiService;
    }

    @Override
    public Observable<MainDomain.MainEntity> getChapters() {
        return sIApiService
                .getChapters()
                .compose(RxSchedulers.ioMain());
    }
}
